﻿namespace UnityEditor.Graphs.AnimationStateMachine
{
    using NUnit.Framework;
    using System;
    using System.Linq;
    using UnityEditor;
    using UnityEditor.Graphs;
    using UnityEngine;

    internal class AnyStateNode : UnityEditor.Graphs.AnimationStateMachine.Node
    {
        private void MakeTransitionCallback()
        {
            base.graphGUI.edgeGUI.BeginSlotDragging(base.outputSlots.First<Slot>(), true, false);
        }

        public override void Move()
        {
            base.Move();
            AnimatorControllerTool.tool.stateMachineGraph.activeStateMachine.anyStatePosition = (Vector3) new Vector2(this.position.x, this.position.y);
        }

        internal override void NodeUI(UnityEditor.Graphs.GraphGUI host)
        {
            base.graphGUI = host as UnityEditor.Graphs.AnimationStateMachine.GraphGUI;
            Assert.NotNull(base.graphGUI);
            Event current = Event.current;
            if (UnityEditor.Graphs.AnimationStateMachine.Node.IsRightClick())
            {
                GenericMenu menu = new GenericMenu();
                menu.AddItem(new GUIContent("Make Transition"), false, new GenericMenu.MenuFunction(this.MakeTransitionCallback));
                menu.ShowAsContext();
                current.Use();
            }
        }

        public override UnityEngine.Object selectionObject
        {
            get
            {
                return this;
            }
        }

        public override UnityEngine.Object undoableObject
        {
            get
            {
                return AnimatorControllerTool.tool.stateMachineGraph.activeStateMachine;
            }
        }
    }
}

